package gui;

import java.awt.Color;
import java.awt.Graphics2D;
import java.io.Serializable;

import fn.Latex;

public class UI_Node implements Serializable {
	private static final long serialVersionUID = -4760190872088356356L;

	private Point pos;
	private String name;

	public UI_Node(Point pos) {
		this.pos = pos;
		this.name = "";
	}

	public Point pos() {
		return pos;
	}

	public String name() {
		return name;
	}

	public void setPos(Point pos) {
		this.pos = pos;
	}

	public UI_Node setName(String name) {
		this.name = name;
		return this;
	}

	public void paint(Graphics2D g, MyView v) {
		g.fillOval((int) v.x(pos.x - 4), (int) v.y(pos.y - 4), (int) v.s(8), (int) v.s(8));
		g.setColor(Color.black);
		g.drawOval((int) v.x(pos.x - 4), (int) v.y(pos.y - 4), (int) v.s(8), (int) v.s(8));
		Latex.draw(name, (int) v.x(pos.x), (int) v.y(pos.y + 8), 16, null, g, Color.black, Color.WHITE);
	}

	@Override
	public int hashCode() {
		return name().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof UI_Node)
			return name.equals(((UI_Node) obj).name);
		else
			return false;
	}
}
